// 添加sequelize实例的导入
const { sequelize } = require('../config/db');
const { DataTypes } = require('sequelize');

// 定义疫苗预约模型
const VaccineAppointment = sequelize.define('VaccineAppointment', {
  id: {
    type: DataTypes.INTEGER,
    primaryKey: true,
    autoIncrement: true
  },
  availableCount: {
    type: DataTypes.INTEGER,
    allowNull: false,
    comment: '剩余数量'
  },
  vaccineType: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '疫苗类型'
  },
  vaccine: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '疫苗名称'
  },
  clinic: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '接种诊所'
  },
  date: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '预约日期'
  },
  time: {
    type: DataTypes.STRING,
    allowNull: false,
    comment: '预约时间段'
  },
  status: {
    type: DataTypes.INTEGER,
    defaultValue: 1,
    comment: '状态：1-预约成功，2-已取消，3-已完成'
  }
}, {
  tableName: 'vaccine_appointments',
  comment: '疫苗预约表',
  timestamps: true, // 自动添加 createdAt 和 updatedAt 字段
  indexes: []
})

module.exports = { VaccineAppointment };